global class CourseController {

    public CourseController(ApexPages.StandardController controller) {

    }
    
    Course__c courses;
    List<Course__c> coursesContainer;
    List<ContentVersion> Contenedor;
    Id ide;
    
    public Course__c getCourses(){
        if(courses == null) {
            /*courses = [     SELECT Test_Count__c, SystemModstamp, OwnerId, Not_duplicate_course__c, Name, LastModifiedDate, 
                            LastModifiedById, LastActivityDate, IsDeleted, Description__c, CurrencyIsoCode, CreatedDate, 
                            CreatedById, Active__c 
                            FROM Course__c
                            WHERE Id='a0YL00000000hg3'];
      
          */  
          courses = new Course__c();
        }
     return courses;
    }
    public List<ContentVersion> getContenedor() {
         //System.Debug(' -------------------------------------------- Entro a getContenedor');
         
         if(contenedor == null){
             contenedor = new List<ContentVersion>();
         
             
             contenedor =[Select Id, VersionNumber, Title, Tes__c, TagCsv, SystemModstamp, RecordTypeId, ReasonForChange, 
             RatingCount, PublishStatus, PositiveRatingCount, PathOnClient, OwnerId, Origin, NegativeRatingCount, LastModifiedDate, 
             LastModifiedById, IsLatest, IsDeleted, FirstPublishLocationId, FileType, FeaturedContentDate, FeaturedContentBoost,
             Description, CurrencyIsoCode, CreatedDate, CreatedById, Course_related__c, ContentUrl, ContentSize, ContentModifiedDate, 
             ContentModifiedById, ContentDocumentId 
             FROM ContentVersion
             //WHERE Course_related__c = 'a0YL00000000hg3'
             ];
           
             
             
             /*co.Title='Hola Mundo';
             contenedor.add(co);
             contenedor.add(co);
             System.Debug(' -------------------------------------------- Entro a getContenedor'+ co.Title);*/
         }
         
         
        return contenedor ;
    
    }
    
        public List<Course__c> getCoursesContainer() {
         
         if(coursesContainer == null){ 
             
             System.Debug(' -------------------------------------------- Entro a getCoursesContainer');
             coursesContainer=[Select c.Active__c, (Select Id, ContentUrl, Title From Content_Course_Related__r) From Course__c c ];
             
             
         }
         
        return coursesContainer;
    
    }
    
    Public List<Course__c> CurrentCourse {
        get{
            if(CurrentCourse == null){
                String CourseId = ApexPages.currentPage().getParameters().get('id');
                CurrentCourse = [SELECT Name, Id, Description__c, Active__c, 
                                (SELECT Id, ContentUrl, Title, CreatedDate, LastModifiedDate, FileType, Link_Preview__c From Content_Course_Related__r)
                                 FROM Course__c c WHERE Id = :CourseId ];
            }
            return CurrentCourse;
        }
        set;
    }
    
     /*
    *** Method SendEmailWithTemplate() ***
    - Objetivo: Método que es un Webservice para llamar a otro
                método en la clase OutboundEmails. Para llamar a
                la función 'OutboundEmails.SendEmailWithTemplate()'
                primero recupera un parametro de su pagina web
                actual. La función OutboundEmails.SendEmailWithTemplate()
                enviara un email a los involucrados en el Announcement
                que tiene un Id igual al parametro enviado.
    */
    static WebService void CreateAnnouncement() {
    PageReference pageCourse = Page.Course;
    String CourseIdParam = ApexPages.currentPage().getParameters().get('id');    
    CourseToAnnouncement.CreateAnnouncement(CourseIdParam);
    }
    
    
}